<template>
  <div id="app" class="app-container">
    <!-- 权限监听器组件 -->
    <PermissionWatcher />
    
    <!-- 登录页面时只显示路由内容，不显示侧边栏 -->
    <router-view v-if="$route.path === '/login'" />
    
    <!-- 登录成功后显示完整界面 -->
    <template v-else>
      <!-- 固定侧边栏 -->
      <aside class="sidebar" :class="{ 'sidebar-collapsed': sidebarCollapsed }">
        <div class="sidebar-content">
          <!-- Logo区域 -->
          <div class="sidebar-header">
            <div class="logo">
              <el-icon><School /></el-icon>
              <span v-if="!sidebarCollapsed">智慧校园门户</span>
            </div>
          </div>
          
          <!-- 用户信息区域 -->
          <div class="sidebar-user-info">
            <el-avatar 
              :size="64" 
              :src="resolveAvatarUrl(userInfo.avatar)"
              :icon="!userInfo.avatar ? 'User' : undefined"
            >
              {{ !userInfo.avatar && userInfo.name ? userInfo.name.charAt(0) : '' }}
            </el-avatar>
            <h3 v-if="!sidebarCollapsed">{{ userInfo.name || '访客用户' }}</h3>
            <p v-if="!sidebarCollapsed && userInfo.username">{{ userInfo.username }}</p>
            <p v-if="!sidebarCollapsed && userInfo.role">{{ getRoleDisplayName(userInfo.role) }}</p>
          </div>
          
          <!-- 导航菜单 -->
          <div class="sidebar-nav">
            <div class="nav-section">
              <h4 v-if="!sidebarCollapsed">主要功能</h4>
              <ul class="nav-menu">
                <li 
                  class="nav-item" 
                  :class="{ active: $route.path === '/home' }"
                  @click="$router.push('/home')"
                >
                  <el-icon><House /></el-icon>
                  <span v-if="!sidebarCollapsed">首页</span>
                </li>
                <li 
                  class="nav-item" 
                  :class="{ active: $route.path === '/notice' }"
                  @click="$router.push('/notice')"
                >
                  <el-icon><Bell /></el-icon>
                  <span v-if="!sidebarCollapsed">通知公告</span>
                </li>
                <li 
                  class="nav-item" 
                  :class="{ active: $route.path === '/academic' }"
                  v-if="userInfo.role !== 'staff' && userInfo.role !== 'STAFF'"
                  @click="$router.push('/academic')"
                >
                  <el-icon><DataAnalysis /></el-icon>
                  <span v-if="!sidebarCollapsed">学工系统</span>
                </li>
                <li 
                  class="nav-item" 
                  :class="{ active: $route.path === '/services' }"
                  v-if="userInfo.role !== 'staff' && userInfo.role !== 'STAFF'"
                  @click="$router.push('/services')"
                >
                  <el-icon><Document /></el-icon>
                  <span v-if="!sidebarCollapsed">学工日志</span>
                </li>
                <li 
                  class="nav-item" 
                  :class="{ active: $route.path === '/resource' }"
                  v-if="userInfo.role !== 'staff' && userInfo.role !== 'STAFF'"
                  @click="$router.push('/resource')"
                >
                  <el-icon><Document /></el-icon>
                  <span v-if="!sidebarCollapsed">资源共享</span>
                </li>
                <li 
                  class="nav-item" 
                  :class="{ active: $route.path === '/social' || $route.path.startsWith('/social/') }"
                  v-if="userInfo.role !== 'staff' && userInfo.role !== 'STAFF'"
                  @click="$router.push('/social')"
                >
                  <el-icon><ChatDotRound /></el-icon>
                  <span v-if="!sidebarCollapsed">社交互动</span>
                </li>
                <li 
                  class="nav-item" 
                  :class="{ active: $route.path === '/repair' || $route.path.startsWith('/repair/') }"
                  @click="$router.push('/repair')"
                >
                  <el-icon><Tools /></el-icon>
                  <span v-if="!sidebarCollapsed">维修申请</span>
                </li>
              </ul>
            </div>
            
            <!-- 个人功能区域 -->
            <div class="nav-section">
              <h4 v-if="!sidebarCollapsed">个人功能</h4>
              <ul class="nav-menu">
                <li 
                  class="nav-item" 
                  :class="{ active: $route.path === '/dashboard' }"
                  @click="$router.push('/dashboard')"
                >
                  <el-icon><User /></el-icon>
                  <span v-if="!sidebarCollapsed">个人中心</span>
                </li>
                <li 
                  class="nav-item" 
                  v-if="userInfo.role === 'admin'|| userInfo.role === 'ADMIN'"
                  :class="{ active: $route.path === '/admin' }"
                  @click="$router.push('/admin')"
                >
                  <el-icon><Setting /></el-icon>
                  <span v-if="!sidebarCollapsed">管理后台</span>
                </li>
                <li 
                  class="nav-item" 
                  v-if="userInfo.role === 'admin'|| userInfo.role === 'ADMIN'"
                  :class="{ active: $route.path === '/admin/resource' }"
                  @click="$router.push('/admin/resource')"
                >
                  <el-icon><Document /></el-icon>
                  <span v-if="!sidebarCollapsed">资源管理</span>
                </li>
                <li 
                  class="nav-item" 
                  v-if="userInfo.role === 'admin'|| userInfo.role === 'ADMIN' || userInfo.role === 'staff' || userInfo.role === 'STAFF'"
                  :class="{ active: $route.path === '/repair/manage' }"
                  @click="$router.push('/repair/manage')"
                >
                  <el-icon><Setting /></el-icon>
                  <span v-if="!sidebarCollapsed">维修管理</span>
                </li>
                <li 
                  class="nav-item" 
                  :class="{ active: $route.path === '/permission-test' }"
                  @click="$router.push('/permission-test')"
                >
                  <el-icon><Key /></el-icon>
                  <span v-if="!sidebarCollapsed">权限测试</span>
                </li>
                <li 
                  class="nav-item" 
                  :class="{ active: $route.path === '/id-test' }"
                  @click="$router.push('/id-test')"
                >
                  <el-icon><Tools /></el-icon>
                  <span v-if="!sidebarCollapsed">ID测试</span>
                </li>
                <li 
                  class="nav-item" 
                  :class="{ active: $route.path === '/logs' }"
                  @click="$router.push('/logs')"
                >
                  <el-icon><Clock /></el-icon>
                  <span v-if="!sidebarCollapsed">历史日志</span>
                </li>
              </ul>
            </div>
            
            <!-- 用户操作 -->
            <div class="nav-section">
              <h4 v-if="!sidebarCollapsed">用户操作</h4>
              <ul class="nav-menu">
                <li class="nav-item" @click="handleRefreshPermissions">
                  <el-icon><Refresh /></el-icon>
                  <span v-if="!sidebarCollapsed">刷新权限</span>
                </li>
                <li class="nav-item" @click="handleLogout">
                  <el-icon><SwitchButton /></el-icon>
                  <span v-if="!sidebarCollapsed">退出登录</span>
                </li>
              </ul>
            </div>
            
            <!-- 联系信息 -->
            <div class="sidebar-footer">
              <div class="contact-info" v-if="!sidebarCollapsed">
                <p><el-icon><Phone /></el-icon> (024) 8972 4302</p>
                <p><el-icon><Message /></el-icon> icampus@sau.edu.cn</p>
              </div>
            </div>
          </div>
    
          <!-- 折叠按钮 -->
          <div class="sidebar-toggle" @click="toggleSidebar">
            <el-icon :size="16">
              <component :is="sidebarCollapsed ? 'ArrowRight' : 'ArrowLeft'" />
            </el-icon>
          </div>
        </div>
        </aside>
        <!-- 主要内容区域 -->
        <main class="main-container" :class="{ 'main-expanded': sidebarCollapsed }">
          <router-view />
        </main>
        
      </template>
    </div>
</template>

<script>
import { ref, computed, onMounted } from 'vue'
import { useStore } from 'vuex'
import { useRouter } from 'vue-router'
import { ElMessage, ElMessageBox } from 'element-plus'
import { 
  School, 
  OfficeBuilding, 
  Monitor, 
  User, 
  SwitchButton,
  House,
  Bell,
  Service,
  Download,
  Guide,
  Setting,
  Phone,
  Message,
  ArrowRight,
  ArrowLeft,
  Clock,
  Refresh,
  ShieldCheck,
  Tools,
  ChatDotRound,
  Document,
  Wallet,
  Key
} from '@element-plus/icons-vue'
import { resolveAvatarUrl } from '@/utils/avatar'
import PermissionWatcher from '@/components/PermissionWatcher.vue'

export default {
  name: 'App',
  components: {
    PermissionWatcher,
    School,
    OfficeBuilding,
    Monitor,
    User,
    SwitchButton,
    House,
    Bell,
    Service,
    Download,
    Guide,
    Setting,
    Phone,
    Message,
    ArrowRight,
    ArrowLeft,
    Clock,
    Refresh,
    ShieldCheck,
    Tools,
    ChatDotRound,
    Document,
    Wallet,
    Key
  },
  setup() {
    const store = useStore()
    const router = useRouter()
    const sidebarCollapsed = ref(localStorage.getItem('autoCollapse') === 'true')
    const themeMode = ref(localStorage.getItem('themeMode') || 'light')

    const userInfo = computed(() => {
      const user = store.state.user.userInfo || store.state.user
      return {
        name: user.name || user.username || '访客用户',
        avatar: user.avatar || '',
        role: user.role || '',
        username: user.username || ''
      }
    })

    const getRoleDisplayName = (role) => {
      const roleNames = {
        student: '学生',
        teacher: '教师',
        admin: '管理员',
        staff: '后勤人员',
        STUDENT: '学生',
        TEACHER: '教师',
        ADMIN: '管理员',
        STAFF: '后勤人员',
        guest: '访客'
      }
      return roleNames[role] || '未知'
    }

    onMounted(() => {
      window.addEventListener('autoCollapseChange', e => {
        sidebarCollapsed.value = e.detail
      })
      window.addEventListener('themeModeChange', e => {
        themeMode.value = e.detail
        document.body.className = themeMode.value === 'dark' ? 'dark-theme' : ''
      })
      // 初始化主题
      document.body.className = themeMode.value === 'dark' ? 'dark-theme' : ''
    })

    const toggleSidebar = () => {
      sidebarCollapsed.value = !sidebarCollapsed.value
      localStorage.setItem('autoCollapse', sidebarCollapsed.value)
      window.dispatchEvent(new CustomEvent('autoCollapseChange', { detail: sidebarCollapsed.value }))
    }

    const handleLogout = () => {
      ElMessageBox.confirm(
        '确定要退出登录吗？',
        '提示',
        {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }
      ).then(() => {
        store.dispatch('user/logout').then(() => {
          ElMessage.success('退出成功')
          router.push('/login')
        })
      })
    }

    const handleRefreshPermissions = () => {
      store.dispatch('user/refreshUserInfo').then(() => {
        ElMessage.success('权限已刷新')
      }).catch(error => {
        console.error('刷新权限失败:', error)
        ElMessage.error('刷新权限失败，请稍后重试')
      })
    }

    return {
      userInfo,
      sidebarCollapsed,
      getRoleDisplayName,
      toggleSidebar,
      handleLogout,
      handleRefreshPermissions,
      resolveAvatarUrl
    }
  }
}
</script>

<style scoped>
.app-container {
  min-height: 100vh;
  background: var(--background-color);
  transition: all 0.3s ease;
}

/* 登录页面时的样式 */
.app-container:has(> .router-view) {
  background: transparent;
  padding: 0;
}

.main-container {
  min-height: 100vh;
  padding: 20px;
  max-width: 1200px;
  margin-left: var(--sidebar-width);
  transition: all 0.3s ease;
  width: calc(100vw - var(--sidebar-width));
}

.main-expanded {
  width: calc(100vw - 60px);
  max-width: none;
  margin-left: 60px;
  padding: 20px 40px;
}

/* 侧边栏样式 */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: linear-gradient(180deg, #ffffff 0%, #f8f9fa 100%);
  border-right: 1px solid #e9ecef;
  z-index: 1001;
  transition: width 0.3s ease;
  overflow: hidden;
  box-shadow: 2px 0 8px rgba(0, 0, 0, 0.1);
}

.sidebar-collapsed {
  width: 60px;
  background: var(--primary-color);
  box-shadow: 2px 0 8px rgba(0,0,0,0.18);
}

.sidebar-content {
  height: 100%;
  display: flex;
  flex-direction: column;
}

.sidebar-header {
  padding: 24px 20px;
  border-bottom: 1px solid #e9ecef;
  background: linear-gradient(135deg, var(--primary-color) 0%, #40a9ff 100%);
  color: white;
  margin: 0 -1px 0 -1px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.sidebar-collapsed .sidebar-header {
  background: var(--primary-color);
  justify-content: center;
}

.logo {
  font-size: 18px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
  letter-spacing: 0.5px;
}

.sidebar-collapsed .logo span {
  display: none;
}

.sidebar-user-info {
  text-align: center;
  padding: 32px 20px 24px;
  border-bottom: 1px solid #e9ecef;
  background: white;
  margin: 0 -1px 0 -1px;
  position: relative;
}

.sidebar-user-info::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 20px;
  right: 20px;
  height: 1px;
  background: linear-gradient(90deg, transparent 0%, #e9ecef 50%, transparent 100%);
}

.sidebar-collapsed .sidebar-user-info {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--primary-color);
  border-bottom: none;
  padding: 12px 0 8px 0;
}

.sidebar-collapsed .sidebar-user-info .el-avatar {
  width: 36px !important;
  height: 36px !important;
  border: 2px solid #444;
  box-shadow: none;
  margin-bottom: 0;
}

.sidebar-user-info h3 {
  margin: 0 0 6px 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--text-color);
}

.sidebar-user-info p {
  margin: 0;
  font-size: 13px;
  color: var(--text-color-secondary);
  background: #f8f9fa;
  padding: 4px 12px;
  border-radius: 12px;
  display: inline-block;
}

.sidebar-collapsed .sidebar-user-info h3,
.sidebar-collapsed .sidebar-user-info p {
  color: #eee !important;
  background: transparent !important;
}

.sidebar-collapsed .sidebar-user-info .el-avatar {
  border: 2px solid #444;
  box-shadow: none;
}

.sidebar-quick-actions {
  padding: 20px;
  background: white;
  border-bottom: 1px solid #e9ecef;
}

.sidebar-collapsed .sidebar-quick-actions {
  display: none;
}

.sidebar-quick-actions .el-button {
  border-radius: 8px;
  font-weight: 500;
  transition: all 0.3s ease;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.sidebar-quick-actions .el-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.sidebar-nav {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  background: #fafbfc;
}

.sidebar-collapsed .sidebar-nav {
  background: var(--primary-color);
  padding: 8px 4px;
}

.nav-section {
  margin-bottom: 32px;
}

.sidebar-collapsed .nav-section {
  margin-bottom: 24px;
}

.nav-section:last-child {
  margin-bottom: 0;
}

.nav-section h4 {
  color: var(--text-color);
  margin-bottom: 16px;
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  padding-left: 4px;
  position: relative;
}

.nav-section h4::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 12px;
  background: var(--primary-color);
  border-radius: 2px;
}

.sidebar-collapsed .nav-section h4 {
  display: none;
}

.nav-menu {
  list-style: none;
  padding: 0;
  margin: 0;
}

.nav-item {
  display: flex;
  align-items: center;
  padding: 14px 16px;
  margin-bottom: 6px;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.3s ease;
  color: var(--text-color);
  white-space: nowrap;
  background: white;
  border: 1px solid transparent;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.sidebar-collapsed .nav-item {
  padding: 14px;
  justify-content: center;
  margin-bottom: 4px;
  background: transparent;
  border: none;
  box-shadow: none;
  color: #eee !important;
}

.nav-item:hover {
  background: linear-gradient(135deg, rgba(24, 144, 255, 0.08) 0%, rgba(24, 144, 255, 0.04) 100%);
  color: var(--primary-color);
  border-color: rgba(24, 144, 255, 0.2);
  transform: translateX(2px);
  box-shadow: 0 4px 12px rgba(24, 144, 255, 0.15);
}

.nav-item.active {
  background: linear-gradient(135deg, var(--primary-color) 0%, #40a9ff 100%);
  color: white;
  border-color: var(--primary-color);
  box-shadow: 0 4px 12px rgba(24, 144, 255, 0.3);
  transform: translateX(2px);
}

.nav-item .el-icon {
  margin-right: 14px;
  font-size: 18px;
  transition: all 0.3s ease;
}

.sidebar-collapsed .nav-item .el-icon {
  margin-right: 0;
  font-size: 20px;
}

.nav-item:hover .el-icon {
  transform: scale(1.1);
}

.nav-item.active .el-icon {
  transform: scale(1.1);
}

.nav-item span {
  font-size: 15px;
  font-weight: 500;
  transition: all 0.3s ease;
}

.sidebar-collapsed .nav-item span {
  display: none;
}

.quick-services {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.sidebar-collapsed .quick-services {
  grid-template-columns: 1fr;
  gap: 8px;
}

.service-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px 16px;
  background: white;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  border: 1px solid #f0f0f0;
  position: relative;
  overflow: hidden;
}

.service-item::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--primary-color) 0%, #40a9ff 100%);
  transform: scaleX(0);
  transition: transform 0.3s ease;
}

.service-item:hover::before {
  transform: scaleX(1);
}

.sidebar-collapsed .service-item {
  padding: 16px 12px;
}

.service-item:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  border-color: rgba(24, 144, 255, 0.2);
}

.service-item .el-icon {
  font-size: 28px;
  color: var(--primary-color);
  margin-bottom: 12px;
  transition: all 0.3s ease;
}

.sidebar-collapsed .service-item .el-icon {
  font-size: 24px;
  margin-bottom: 8px;
}

.service-item:hover .el-icon {
  transform: scale(1.1);
  color: #40a9ff;
}

.service-item span {
  font-size: 13px;
  color: var(--text-color);
  text-align: center;
  font-weight: 500;
}

.sidebar-collapsed .service-item span {
  display: none;
}

.sidebar-footer {
  padding: 20px;
  border-top: 1px solid #e9ecef;
  background: white;
  margin: 0 -1px -1px -1px;
  position: relative;
}

.sidebar-footer::before {
  content: '';
  position: absolute;
  top: 0;
  left: 20px;
  right: 20px;
  height: 1px;
  background: linear-gradient(90deg, transparent 0%, #e9ecef 50%, transparent 100%);
}

.sidebar-collapsed .sidebar-footer {
  padding: 12px 10px;
}


.sidebar-toggle {
  position: absolute;
  top: 50%;
  right: -16px;
  transform: translateY(-50%);
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, var(--primary-color) 0%, #40a9ff 100%);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(24, 144, 255, 0.3);
  transition: all 0.3s ease;
  z-index: 1002;
  border: 2px solid white;
}

.sidebar-toggle:hover {
  background: linear-gradient(135deg, #40a9ff 0%, #69c0ff 100%);
  transform: translateY(-50%) scale(1.1);
  box-shadow: 0 6px 16px rgba(24, 144, 255, 0.4);
}

.sidebar-toggle .el-icon {
  transition: transform 0.3s ease;
}

.sidebar-toggle:hover .el-icon {
  transform: scale(1.1);
}


/* 响应式设计 */
@media (max-width: 768px) {
  .app-container {
    padding-left: 0;
  }
  
  .sidebar {
    transform: translateX(-100%);
  }
  
  .sidebar.mobile-open {
    transform: translateX(0);
  }
  
  .main-container {
    width: 100vw;
    margin-left: 0;
    padding: 20px 16px;
  }
  
  .main-expanded {
    width: 100vw;
    margin-left: 0;
    padding: 20px 16px;
  }
  
  
  .quick-services {
    grid-template-columns: 1fr;
  }
}

/* 动画效果 */
.fade-enter-active, .fade-leave-active {
  transition: opacity 0.3s;
}

.fade-enter, .fade-leave-to {
  opacity: 0;
}

.slide-enter-active, .slide-leave-active {
  transition: transform 0.3s;
}

.slide-enter, .slide-leave-to {
  transform: translateX(-100%);
}

/* 账户设置抽屉样式 */
.account-settings-drawer {
  --el-drawer-bg-color: #f8f9fa;
}

.account-settings-drawer .el-drawer__header {
  background: linear-gradient(135deg, var(--primary-color) 0%, #40a9ff 100%);
  color: white;
  margin-bottom: 0;
  padding: 20px;
}

.account-settings-drawer .el-drawer__title {
  color: white;
  font-weight: 600;
}

.account-settings-drawer .el-drawer__close-btn {
  color: white;
}

.account-settings-drawer .el-drawer__close-btn:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

/* 深色主题下优化 */
body.dark-theme .sidebar {
  background: linear-gradient(180deg, #23272e 0%, #181c20 100%);
  border-right: 1px solid #222;
}
body.dark-theme .sidebar-header {
  background: linear-gradient(135deg, #23272e 0%, #181c20 100%);
  color: #eee;
}
body.dark-theme .sidebar-user-info {
  background: #23272e;
  border-bottom: 1px solid #222;
}
body.dark-theme .sidebar-nav {
  background: #181c20;
}
body.dark-theme .nav-item {
  background: #23272e;
  color: #eee;
  border: 1px solid #23272e;
}
body.dark-theme .nav-item.active {
  background: #40a9ff;
  color: #fff;
  border-color: #40a9ff;
}
body.dark-theme .nav-item:hover {
  background: #222;
  color: #40a9ff;
}
body.dark-theme .sidebar-toggle {
  background: #23272e;
  color: #40a9ff;
  border: 2px solid #23272e;
}
body.dark-theme .sidebar-footer {
  background: #23272e;
  border-top: 1px solid #222;
}
body.dark-theme .main-container {
  background: #181c20;
  color: #eee;
}
body.dark-theme .main-container .card {
  background: #23272e;
  color: #eee;
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
}
body.dark-theme .main-container .card-header {
  border-bottom: 1px solid #222;
}
body.dark-theme .main-container .el-descriptions {
  background: #23272e;
  color: #eee;
}
body.dark-theme .main-container .el-tag {
  background: #222;
  color: #40a9ff;
}
body.dark-theme .main-container .el-button {
  background: #23272e;
  color: #40a9ff;
  border: 1px solid #40a9ff;
}
body.dark-theme .main-container .el-button:hover {
  background: #40a9ff;
  color: #fff;
}
body.dark-theme .nav-item span {
  color: #eee !important;
}
body.dark-theme .sidebar-collapsed .nav-item {
  color: #eee !important;
}
body.dark-theme .sidebar-collapsed .nav-item.active {
  color: #40a9ff !important;
}
body.dark-theme .sidebar-collapsed .nav-item:hover {
  color: #40a9ff !important;
}
body.dark-theme .main-container,
body.dark-theme .main-container .card,
body.dark-theme .main-container .card-header,
body.dark-theme .main-container .el-descriptions,
body.dark-theme .main-container .el-tag,
body.dark-theme .main-container .el-button {
  color: #181818 !important;
}
body.dark-theme .main-container .card-header,
body.dark-theme .main-container .el-descriptions__title,
body.dark-theme .main-container .el-descriptions__label {
  color: #181818 !important;
  font-weight: bold;
}

/* 深色模式下账户信息卡片整体和谐美化 */
body.dark-theme .account-info-card {
  background: #20232a !important;
  color: #e6e6e6 !important;
  border-radius: 16px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.32);
  border: 1px solid #23272e;
}
body.dark-theme .account-info-card .user-avatar {
  background: transparent !important;
  border-right: 1px solid #23272e;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 32px 0 24px 0;
}
body.dark-theme .account-info-card .user-avatar h3,
body.dark-theme .account-info-card .user-avatar p {
  color: #fff !important;
}
body.dark-theme .account-info-card .el-tag {
  background: #23272e !important;
  color: #40a9ff !important;
  border: 1px solid #40a9ff !important;
}
body.dark-theme .account-info-card .el-button {
  background: #40a9ff !important;
  color: #fff !important;
  border: none !important;
}
body.dark-theme .account-info-card .el-button:hover {
  background: #69c0ff !important;
  color: #23272e !important;
}
body.dark-theme .account-info-card .account-details {
  background: transparent !important;
  color: #e6e6e6 !important;
  padding: 32px 0 24px 0;
}
body.dark-theme .account-info-card .account-details h4 {
  color: #fff !important;
  font-weight: bold;
  margin-bottom: 18px;
}
body.dark-theme .account-info-card .el-descriptions {
  background: transparent !important;
  color: #e6e6e6 !important;
}
body.dark-theme .account-info-card .el-descriptions__label {
  color: #aaa !important;
  font-weight: 500;
}
body.dark-theme .account-info-card .el-descriptions__cell {
  color: #fff !important;
}
</style>
